package com.example.springbgootjwt.controller;

import com.example.springbgootjwt.entity.ExceptionClass;
import com.example.springbgootjwt.entity.User;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class ExceptionController {

    @GetMapping("calculate")
    public String calculate(){
        return String.valueOf(1/0);
    }

    @GetMapping("getS")
    public String getS(){
        String s =null;
        return s.toString();
    }

    @GetMapping("getModelAttribute1")
    public Object getModelAttribute1(Model model){
        Map<String, Object> stringObjectMap = model.asMap();
        return stringObjectMap.get("string");
    }

    @GetMapping("getModelAttribute2")
    public Object getModelAttribute12(Model model){
        Map<String, Object> stringObjectMap = model.asMap();
        return stringObjectMap.get("info");
    }

    @GetMapping("getModelAttribute3")
    public Object getModelAttribute13(Model model){
        Map<String, Object> stringObjectMap = model.asMap();
        return stringObjectMap.get("message");
    }

    @PostMapping("addSameField")
    public void addSameField(User user, ExceptionClass exceptionClass){
        System.out.println(user);
        System.out.println(exceptionClass);
    }

}
